﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GtsServer.Service.Model;
using GtsServer.DAL;
using System.Data;

namespace GtsServer.Service.Controller
{
    public class ReceiveCaidanController
    {
        ReceiveCaidanRequest request = new ReceiveCaidanRequest();
        public ReceiveCaidanController(ReceiveCaidanRequest model)
        {
            request = model;
        }

        public ReceiveCaidanResponse ReceiveCaidan()
        {
            ReceiveCaidanResponse response = new ReceiveCaidanResponse();

            TaskPrizeDAL dal = new TaskPrizeDAL();
            string userAccount = BaseController.Account(request.info);

            if (string.IsNullOrEmpty(userAccount))
                return response;

            response.result = 0;
            DataSet ds = dal.ReceiveCaidan(userAccount, request.index);//? 1 : 0;
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                response.result = 1;
                response.egg = Convert.ToInt32(ds.Tables[0].Rows[0]["PrizeCount"].ToString());
            }

            return response;
        }
    }
}
